package com.atguigu.flink.day03;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.LocalStreamEnvironment;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author Felix
 * @date 2023/12/2
 * 该案例演示了Flink的环境准备
 */
public class Flink01_env {
    public static void main(String[] args) throws Exception {
        //准备环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        //获取本地执行环境 不带webUI
        // LocalStreamEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
        //获取本地执行环境 带webUI
        //需要在pom.xml文件中添加 flink-runtime-web依赖
        // StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());
        //创建远程执行环境
        // StreamExecutionEnvironment env
        //     = StreamExecutionEnvironment.createRemoteEnvironment("hadoop102", 8081, "D:\\dev\\workspace\\bigdata0710-parent\\flink0710\\target\\flink0710-1.0-SNAPSHOT.jar");

        //指定处理模式(流-默认、批)
        // env.setRuntimeMode(RuntimeExecutionMode.BATCH);
        //还可以在提交应用的时候  通过参数指定模式 bin/flink run -Dexecution.runtime-mode=BATCH

        env
            .readTextFile("/opt/module/flink-1.17.0/word.txt")
            .print();

        //触发程序执行(提交job):了解         1 app => n job
        // env.execute();
        env.executeAsync();
        StreamExecutionEnvironment env1 = StreamExecutionEnvironment.getExecutionEnvironment();
        // env1.execute();
        env1.executeAsync();
    }
}
